package ycl.important.common.base.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import ycl.important.common.base.entity.BaseRegionEntity;
import ycl.important.common.base.mapper.BaseRegionMapper;
import ycl.important.common.base.service.BaseRegionService;
import ycl.important.common.utils.AnnotationUtil;

import java.util.List;

/**
 * 地区基类逻辑层
 *
 * @author: YCL
 * @date: 2021-10-06 21:25:43
 */
@Service
@Lazy
public abstract class
BaseRegionServiceImpl<M extends BaseRegionMapper<T>, T extends BaseRegionEntity>
		extends BaseServiceImpl<M, T>
		implements BaseRegionService<T> {

	@Autowired
	private BaseRegionMapper<T> baseRegionMapper;



	@Override
	public T getByCode(String code, Class<T> c) {
		String tableName = AnnotationUtil.getTableName(c);
		return baseRegionMapper.getByCode(tableName, code);
	}


	@Override
	public List<T> getByParentCode(String code, Class<T> c) {
		String tableName = AnnotationUtil.getTableName(c);
		return baseRegionMapper.getByParentCode(tableName, code);
	}
}
